home *** CD-ROM | disk | FTP | other *** search
/ Game Programming in C++ - Start to Finish / GameProgrammingS.iso / developer_install / CEGUISDK-0.4.1-VC6-STLport.exe / {app} / Samples / common / include / Win32AppHelper.h < prev    next >
C/C++ Source or Header  |  2005-11-25  |  3KB  |  88 lines

  1. /************************************************************************
  2.     filename:   Win32AppHelper.h
  3.     created:    17/10/2004
  4.     author:     Paul D Turner
  5. *************************************************************************/
  6. /*************************************************************************
  7.     Crazy Eddie's GUI System (http://www.cegui.org.uk)
  8.     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
  9.  
  10.     This library is free software; you can redistribute it and/or
  11.     modify it under the terms of the GNU Lesser General Public
  12.     License as published by the Free Software Foundation; either
  13.     version 2.1 of the License, or (at your option) any later version.
  14.  
  15.     This library is distributed in the hope that it will be useful,
  16.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  18.     Lesser General Public License for more details.
  19.  
  20.     You should have received a copy of the GNU Lesser General Public
  21.     License along with this library; if not, write to the Free Software
  22.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  23. *************************************************************************/
  24. #ifndef _Win32AppHelper_h_
  25. #define _Win32AppHelper_h_
  26.  
  27. #if defined( __WIN32__ ) || defined( _WIN32 )
  28. #   define WIN32_LEAN_AND_MEAN
  29. #   include <windows.h>
  30.  
  31. #include <dinput.h>
  32.  
  33. // undefine Microsoft macro evilness
  34. #   undef min
  35. #   undef max
  36. #endif
  37.  
  38. #if defined(_WIN32)
  39. #  pragma comment(lib, "dinput8.lib")
  40. #  pragma comment(lib, "dxguid.lib")
  41. #endif
  42.  
  43.  
  44. /*!
  45. \brief
  46.     All static utility class containing helper / common functions used for the Win32 apps
  47. */
  48. class Win32AppHelper
  49. {
  50. public:
  51.     struct DirectInputState
  52.     {
  53.         DirectInputState() : directInput(0), keyboardDevice(0)
  54.         {}
  55.  
  56.         LPDIRECTINPUT8 directInput;
  57.         LPDIRECTINPUTDEVICE8 keyboardDevice ;
  58.     };
  59.  
  60.     static HWND createApplicationWindow(int width, int height);
  61.     static void mouseEnters(void);
  62.     static void mouseLeaves(void);
  63.     static bool initialiseDirectInput(HWND window, Win32AppHelper::DirectInputState& dis);
  64.     static void cleanupDirectInput(Win32AppHelper::DirectInputState& dis);
  65.     static void doDirectInputEvents(const Win32AppHelper::DirectInputState& dis);
  66.     static bool doWin32Events(bool& idle);
  67.     static LRESULT CALLBACK wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
  68.  
  69.     /*************************************************************************
  70.         Constants
  71.     *************************************************************************/
  72.     // name of the application, used for class and window creation
  73.     static const TCHAR  APPLICATION_NAME[];
  74.  
  75.     // error strings displayed during initialisation
  76.     static const TCHAR  REGISTER_CLASS_ERROR[];
  77.     static const TCHAR  CREATE_WINDOW_ERROR[];
  78.  
  79.     // other error strings used
  80.     static const TCHAR  CREATE_D3D_ERROR[];
  81.     static const TCHAR  CREATE_DEVICE_ERROR[];
  82.  
  83. private:
  84.     static bool d_mouseInWindow;
  85. };
  86.  
  87. #endif  // end of guard _Win32AppHelper_h_
  88.